package com.elai.tags.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elai.common.annotation.Log;
import com.elai.common.core.controller.BaseController;
import com.elai.common.core.domain.AjaxResult;
import com.elai.common.enums.BusinessType;
import com.elai.tags.domain.BaseUserPortraitCompents;
import com.elai.tags.service.IBaseUserPortraitCompentsService;
import com.elai.common.utils.poi.ExcelUtil;
import com.elai.common.core.page.TableDataInfo;

/**
 * 画像组件Controller
 * 
 * @author elai
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/tag/portraitCompents")
public class BaseUserPortraitCompentsController extends BaseController
{
    @Autowired
    private IBaseUserPortraitCompentsService baseUserPortraitCompentsService;

    /**
     * 查询画像组件列表
     */
    @PreAuthorize("@ss.hasPermi('tag:portraitCompents:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseUserPortraitCompents baseUserPortraitCompents)
    {
        startPage();
        List<BaseUserPortraitCompents> list = baseUserPortraitCompentsService.selectBaseUserPortraitCompentsList(baseUserPortraitCompents);
        return getDataTable(list);
    }

    /**
     * 导出画像组件列表
     */
    @PreAuthorize("@ss.hasPermi('tag:portraitCompents:export')")
    @Log(title = "画像组件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BaseUserPortraitCompents baseUserPortraitCompents)
    {
        List<BaseUserPortraitCompents> list = baseUserPortraitCompentsService.selectBaseUserPortraitCompentsList(baseUserPortraitCompents);
        ExcelUtil<BaseUserPortraitCompents> util = new ExcelUtil<BaseUserPortraitCompents>(BaseUserPortraitCompents.class);
        return util.exportExcel(list, "画像组件数据");
    }

    /**
     * 获取画像组件详细信息
     */
    @PreAuthorize("@ss.hasPermi('tag:portraitCompents:query')")
    @GetMapping(value = "/{portraitId}")
    public AjaxResult getInfo(@PathVariable("portraitId") Long portraitId)
    {
        return AjaxResult.success(baseUserPortraitCompentsService.selectBaseUserPortraitCompentsById(portraitId));
    }

    /**
     * 新增画像组件
     */
    @PreAuthorize("@ss.hasPermi('tag:portraitCompents:add')")
    @Log(title = "画像组件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseUserPortraitCompents baseUserPortraitCompents)
    {
        return toAjax(baseUserPortraitCompentsService.insertBaseUserPortraitCompents(baseUserPortraitCompents));
    }

    /**
     * 修改画像组件
     */
    @PreAuthorize("@ss.hasPermi('tag:portraitCompents:edit')")
    @Log(title = "画像组件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseUserPortraitCompents baseUserPortraitCompents)
    {
        return toAjax(baseUserPortraitCompentsService.updateBaseUserPortraitCompents(baseUserPortraitCompents));
    }

    /**
     * 删除画像组件
     */
    @PreAuthorize("@ss.hasPermi('tag:portraitCompents:remove')")
    @Log(title = "画像组件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{portraitIds}")
    public AjaxResult remove(@PathVariable Long[] portraitIds)
    {
        return toAjax(baseUserPortraitCompentsService.deleteBaseUserPortraitCompentsByIds(portraitIds));
    }
}
